//引入request
import { request  , requestmock} from "@/utils/http";

//请求banner数据
export const requestMockList = () => {
    return requestmock.get("/banner")
}

//请求floor数据
export const requestFloorList = () => {
    return requestmock.get("/floor")
}




//1.三级列表请求
export const requestCateGoryList = () => {
    return request.get("/api/product/getBaseCategoryList")
}

//2.商品详情请求
export const requestSearchList = (searchParams) => {
    return request.post("/api/list" , searchParams)
}

//3.单个商品信息请求
export const requestDetailList = (skuid) => {
    return request.get(`/api/item/${skuid}`)
}


//4.添加购物车 和 修改购物车数量的请求
export const requestAddOrUpdateNumCart = ({ skuId, skuNum }) => {
    return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
}

//5.获取购物车列表
export const requestShopCart = () => {
    return request.get(`/api/cart/cartList`)
}

//6.切换单个商品状态
export const requestSingleChecked = ({skuId , isChecked}) => {
    return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
}

//7.切换全部商品状态
export const requestAllChecked = (isChecked , skuIdList) => {
    console.log(isChecked , skuIdList);
    return request.post(`/api/cart/batchCheckCart/${isChecked}` , skuIdList )
}

//8.删除单个商品
export const requestDeteleSingle= (skuId) => {
    return request.delete(`/api/cart/deleteCart/${skuId}`)
}

//9.删除已选择的商品
export const requestDeteleAllChecked= (skuIdList) => {
    return request.delete(`/api/cart/batchDeleteCart` , {
        data: skuIdList
    })
}


//注册页面:
//10.获取验证码请求
export const requestGetCode = (phone) => {
    return request.get(`/api/user/passport/sendCode/${phone}`)
}

//11.注册请求
export const requestRegistr = (userInfo) => {
    return request.post(`/api/user/passport/register` , userInfo)
}

//12.登录请求(为了拿到token)
export const requestLogin = (userInfo) => {
    return request.post(`/api/user/passport/login` , userInfo)
}

//13.获取用户信息请求(根据token请求用户信息)
export const requestUserInfo = () => {
    return request.get("/api/user/passport/auth/getUserInfo")
}

//14.退出登录请求
export const requestLogout = () => {
    return request.get("/api/user/passport/logout");
};



//15.交易页数据请求
export const requestTradeInfo = () => {
    return request.get("/api/order/auth/trade")
}

//16.请求address数据
export const requestTradeAddress = () => {
    return requestmock.get("/address");
};

//17.提交订单请求
export const requestAddTrade = (tradeNo , tradeInfo) => {
    return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}` , tradeInfo)
}


//支付页面
//18.根据订单号获取订单详细信息请求
export const requestPayDetail = (orderId) => {
    return request.get(`/api/payment/weixin/createNative/${orderId}`);
};

//19.查询用户某个订单的支付状态
export const requestPayStatus = (orderId) => {
    return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}


//我的订单页面
//20.获取我的订单列表
export const requestOrderList = ({page , limit}) => {
    return request.get(`/api/order/auth/${page}/${limit}`)
}







